//
//  consiceViewController.m
//  weather
//
//  Created by zd2011 on 12-11-21.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "consiceViewController.h"

@interface consiceViewController ()
//判断星期几
-(NSString *)isWeek:(NSString *)weekStr;

@end

@implementation consiceViewController

@synthesize set;
@synthesize table;
@synthesize delegate;

@synthesize cityDict3;
- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    //设置背景
    UIImageView *tableBg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"city"]];
    [self.table setBackgroundView:tableBg];
    //得到天气资料
    self.cityDict3=[self.delegate returnWeatherInfoTo:self];
    
    [self display];
    
}


-(NSString *)isWeek:(NSString*)weekStr{
    
    if([weekStr isEqualToString:@"星期一"])
        return @"星期二";
    if ([weekStr isEqualToString:@"星期二"])
        return @"星期三";
    if([weekStr isEqualToString:@"星期三"])
        return @"星期四";
    if([weekStr isEqualToString:@"星期四"])
        return @"星期五";
    if([weekStr isEqualToString:@"星期五"])
        return @"星期六";
    if([weekStr isEqualToString:@"星期六"])
        return @"星期日";
    if([weekStr isEqualToString:@"星期日"])
        return @"星期一";


    
}
//显示的函数
-(void)display{
   
    NSLog(@"%d ", [self.set count]);
    
    for (UILabel *label in self.set) {
         NSString *weekStr1=[self.cityDict3 objectForKey:@"week"];
        switch (label.tag) {
            case 1:
                label.text=[self.cityDict3 objectForKey:@"weather1"];
                break;
            case 2:
            
                label.text=[self.cityDict3 objectForKey:@"week" ];
                
                
                break;
    
            case 3:
                label.text=[self.cityDict3 objectForKey:@"temp1"];
                break;
            case 4:
                label.text=[self.cityDict3 objectForKey:@"wind1"];
                break;
                
            case 5:
                label.text=[self.cityDict3 objectForKey:@"weather2"];
                break;
            case 6:
                weekStr1=[self isWeek:weekStr1];
                label.text=weekStr1;
                
                
                break;
    
            case 7:
                label.text=[self.cityDict3 objectForKey:@"temp2"];
                break;
            case 8:
                label.text=[self.cityDict3 objectForKey:@"wind2"];
                break;
                
            case 9:
                label.text=[self.cityDict3 objectForKey:@"weather3"];
                
                break;
            case 10:
                weekStr1=[self isWeek:weekStr1];
                weekStr1=[self isWeek:weekStr1];
                label.text=weekStr1;
                
                break;
            case 11:
                label.text=[self.cityDict3 objectForKey:@"temp3"];
                break;
            case 12:
                label.text=[self.cityDict3 objectForKey:@"wind3"];
                break;
                
            case 13:
                label.text=[self.cityDict3 objectForKey:@"weather4"];
                break;
            case 14:
                weekStr1=[self isWeek:weekStr1];
                weekStr1=[self isWeek:weekStr1];
                weekStr1=[self isWeek:weekStr1];
                label.text=weekStr1;
                break;
            case 15:
                label.text=[self.cityDict3 objectForKey:@"temp4"];
                break;

            case 16:
                label.text=[self.cityDict3 objectForKey:@"wind4"];
                break;
                
            default:
                break;
        }
                
    }

}

- (void)viewDidUnload
{
    [self setTable:nil];

    [self setSet:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}




@end
